package com.example.zhugenew.adapter.newhouses;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.zhugenew.R;
import com.example.zhugenew.bean.newhouses.NewListBean;

import java.util.List;

public class NewHouseListAdapter extends RecyclerView.Adapter<NewHouseListAdapter.ViewHolder> {
    private List<NewListBean.DataBeanX.DataBean> list;
    private Context context;

    public NewHouseListAdapter(List<NewListBean.DataBeanX.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.layout_newhouse_list_item, parent, false);
//        new ViewHolder(inflate)
        return new ViewHolder(inflate) ;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Glide.with(context).load(list.get(position).getThumb()).into(holder.thumb);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private final ImageView thumb;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            thumb = itemView.findViewById(R.id.list_image);
        }
    }
}
 